package com.example.covid.controller;

import com.example.covid.model.VirusData;
import com.example.covid.model.sumdata;
import com.example.covid.service.serviceconfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
import static com.example.covid.service.serviceconfig.Sum;
import static com.example.covid.service.serviceconfig.newcase;
import static org.springframework.web.bind.annotation.RequestMethod.GET;

@RestController
@RequestMapping
public class DataController {
    @Autowired
    private serviceconfig Service;
    @RequestMapping(value="/findByCountry",method = GET)
    public List<VirusData> findByCountry(String country){
        return Service.findByCountry(country);
    }
    @RequestMapping(value="/findSum",method=GET)
    public sumdata findSum(){
        return new sumdata(Sum,newcase,new Date());
    }
    @RequestMapping(value="/findAll",method=GET)
    public List<VirusData> FindAll(){return Service.FindAll();}
    @RequestMapping(value = "/findByProvince",method = GET)
    public VirusData findByProvince(String province){
        return Service.findByProvince(province);
    }


}
